#!/usr/bin/env python 
# -*- coding: utf-8 -*-
# @Time    : 2023/4/3 11:18
# @Author  : WJQ
# @Site    : 
# @File    : wx_js.py
# @Software: PyCharm
TAB_INIT_JS = """
// 修改浏览器对象的属性
Object.defineProperty(navigator, 'platform', {
    get: function () { return 'win32'; }
});
"""

GET_ELEMENT_XPATH = """
    function getElementXPath(element) {
        if (element && element.id) {
            return '//*[@id="' + element.id + '"]';
        } else {
            var path = '';
            for (; element && element.nodeType == 1; element = element.parentNode) {
                var index = 1;
                for (var sibling = element.previousSibling; sibling; sibling = sibling.previousSibling) {
                    if (sibling.nodeType == 1 && sibling.tagName == element.tagName) {
                        index++;
                    }
                }
                path = '/' + element.tagName.toLowerCase() + '[' + index + ']' + path;
            }
            return path;
        }
    }

    return getElementXPath(arguments[0]);
"""